home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / wink24h / src / wind.c < prev    next >
Text File  |  1994-06-01  |  8KB  |  313 lines

  1. #include    <stdio.h>
  2. #include    <stdlib.h>
  3. #include    "defs.h"
  4.  
  5. typedef struct _EP {
  6.     struct _EP  *next;
  7.     int         actno;
  8.     int         actpos;
  9.     long        pos;
  10.     long        line;
  11. } EDT_PTR;
  12.  
  13. typedef struct _WINDFP {
  14.     struct _WINDFP  *nxt_wfp;
  15.     EDT_PTR  *edt_top_wfp;
  16.     LONG    top_ptr_wfp;
  17.     LONG    lin_ptr_wfp;
  18.     LONG    ent_ptr_wfp;
  19.     LONG    btm_ptr_wfp;
  20.     int     Cur_X_wfp,Cur_Y_wfp;
  21.     BOOL    Wrt_flg_wfp;
  22.     int     Line_no_wfp;
  23.     short   Line_X_wfp,Line_Y_wfp;
  24.     short   Woff_X_wfp,Woff_Y_wfp; 
  25.     short   Wsiz_X_wfp,Wsiz_Y_wfp;
  26.     short   Wscr_X_wfp,Wscr_Y_wfp;
  27.     short   Wind_flg_wfp,dlp_flg_wfp;
  28.     short   WCol_wfp;
  29.     char    name_wfp[80];
  30. } WINDFP;
  31.  
  32. extern EDT_PTR  *edt_top;
  33. extern int      Line_no;
  34. extern char     *file_name;
  35. extern UCHAR    vram[];
  36. extern short    Line_X,Line_Y;
  37. extern short    Woff_X,Woff_Y; 
  38. extern short    Wsiz_X,Wsiz_Y;
  39. extern short    Wscr_X,Wscr_Y;
  40. extern short    Wind_flg,dlp_flg;
  41. extern short    COLOR;
  42. extern char     *SPCSTR;
  43.  
  44. extern void  strcpy();
  45. extern void  memcpy();
  46. extern void  memset();
  47. extern void  Buf_init();
  48. extern void  Set_file_name();
  49. extern void  Set2_file_name();
  50. extern int   New_link();
  51. extern void  Kill_link();
  52. extern void  Set_vram();
  53. extern void  Dsp_vram();
  54. extern void  Dsp_wrt_flg();
  55. extern void  Dsp_free();
  56. extern void  wrtstr();
  57. extern int   Get_key();
  58. extern int   Sel_menu();
  59.  
  60. static WINDFP   *topwfp=NULL;
  61. static short    ReSize_flg=FALSE;
  62.  
  63. int     New_wind(file)
  64. char    *file;
  65. {
  66.     WINDFP  *wfp;
  67.     char    *p;
  68.  
  69.     if ( (wfp = (WINDFP *)malloc(sizeof(WINDFP))) == NULL )
  70.     return ERR;
  71.  
  72.     wfp->nxt_wfp = NULL;
  73.     wfp->edt_top_wfp = edt_top;
  74.     wfp->top_ptr_wfp = top_ptr;
  75.     wfp->lin_ptr_wfp = lin_ptr;
  76.     wfp->ent_ptr_wfp = ent_ptr;
  77.     wfp->btm_ptr_wfp = btm_ptr;
  78.     wfp->Wrt_flg_wfp = Wrt_flg;
  79.     wfp->Line_no_wfp = Line_no;
  80.     wfp->Cur_X_wfp = Cur_X; wfp->Cur_Y_wfp = Cur_Y;
  81.     wfp->Line_X_wfp = Line_X; wfp->Line_Y_wfp = Line_Y;
  82.     wfp->Woff_X_wfp = Woff_X; wfp->Woff_Y_wfp = Woff_Y;
  83.     wfp->Wscr_X_wfp = Wscr_X; wfp->Wscr_Y_wfp = Wscr_Y;
  84.     wfp->Wsiz_X_wfp = Wsiz_X; wfp->Wsiz_Y_wfp = Wsiz_Y;
  85.     wfp->Wind_flg_wfp = Wind_flg; wfp->dlp_flg_wfp = dlp_flg;
  86.     wfp->WCol_wfp = COLOR;
  87.     if ( (p = file_name) == NULL )
  88.     p = "DUMMY.TED";
  89.     strcpy(wfp->name_wfp,p);
  90.  
  91.     if ( New_link() != FALSE ) {
  92.     free(wfp);
  93.     return ERR;
  94.     }
  95.     Buf_init(file);
  96.     Set_file_name(file);
  97.     Woff_X = Woff_Y = 0;
  98.     Wsiz_X = MAX_X; Wsiz_Y = MAX_Y;
  99.     Wind_flg = dlp_flg = FALSE;
  100.     COLOR = 7;
  101.  
  102.     if ( topwfp != NULL )
  103.     wfp->nxt_wfp = topwfp;
  104.     topwfp = wfp;
  105.  
  106.     return FALSE;
  107. }
  108. void    Chng_wind()
  109. {
  110.     WINDFP  wfp,*p,*s;
  111.     char    *dm;
  112.  
  113.     if ( topwfp == NULL )
  114.     return;
  115.  
  116.     wfp.nxt_wfp = topwfp->nxt_wfp;
  117.     wfp.edt_top_wfp = edt_top;
  118.     wfp.top_ptr_wfp = top_ptr;
  119.     wfp.lin_ptr_wfp = lin_ptr;
  120.     wfp.ent_ptr_wfp = ent_ptr;
  121.     wfp.btm_ptr_wfp = btm_ptr;
  122.     wfp.Wrt_flg_wfp = Wrt_flg;
  123.     wfp.Line_no_wfp = Line_no;
  124.     wfp.Cur_X_wfp = Cur_X; wfp.Cur_Y_wfp = Cur_Y;
  125.     wfp.Line_X_wfp = Line_X; wfp.Line_Y_wfp = Line_Y;
  126.     wfp.Woff_X_wfp = Woff_X; wfp.Woff_Y_wfp = Woff_Y;
  127.     wfp.Wscr_X_wfp = Wscr_X; wfp.Wscr_Y_wfp = Wscr_Y;
  128.     wfp.Wsiz_X_wfp = Wsiz_X; wfp.Wsiz_Y_wfp = Wsiz_Y;
  129.     wfp.Wind_flg_wfp = Wind_flg; wfp.dlp_flg_wfp = dlp_flg;
  130.     wfp.WCol_wfp = COLOR;
  131.     if ( (dm = file_name) == NULL )
  132.     dm = "DUMMY.TED";
  133.     strcpy(wfp.name_wfp,dm);
  134.  
  135.     top_ptr = topwfp->top_ptr_wfp;
  136.     lin_ptr = topwfp->lin_ptr_wfp;
  137.     ent_ptr = topwfp->ent_ptr_wfp;
  138.     btm_ptr = topwfp->btm_ptr_wfp;
  139.     Cur_X = topwfp->Cur_X_wfp;
  140.     Cur_Y = topwfp->Cur_Y_wfp;
  141.     Wrt_flg = topwfp->Wrt_flg_wfp;
  142.     Line_no = topwfp->Line_no_wfp;
  143.     Line_X = topwfp->Line_X_wfp; Line_Y = topwfp->Line_Y_wfp;
  144.     Woff_X = topwfp->Woff_X_wfp; Woff_Y = topwfp->Woff_Y_wfp;
  145.     Wscr_X = topwfp->Wscr_X_wfp; Wscr_Y = topwfp->Wscr_Y_wfp;
  146.     Wsiz_X = topwfp->Wsiz_X_wfp; Wsiz_Y = topwfp->Wsiz_Y_wfp;
  147.     Wind_flg = topwfp->Wind_flg_wfp; dlp_flg = topwfp->dlp_flg_wfp;
  148.     COLOR = topwfp->WCol_wfp;
  149.     if ( ReSize_flg == FALSE )
  150.         Set_file_name(topwfp->name_wfp);
  151.     else
  152.         Set2_file_name(topwfp->name_wfp);
  153.     edt_top = topwfp->edt_top_wfp;
  154.     if ( Wind_flg == ERR )
  155.     Wind_flg = TRUE;
  156.  
  157.     memcpy(topwfp,&wfp,sizeof(WINDFP));
  158.  
  159.     if ( topwfp->nxt_wfp != NULL ) {
  160.         for ( s = p = topwfp->nxt_wfp ; (p = s->nxt_wfp) != NULL ; s = p );
  161.     s->nxt_wfp = topwfp;
  162.     p = topwfp->nxt_wfp;
  163.     topwfp->nxt_wfp = NULL;
  164.     topwfp = p;
  165.     }
  166. }
  167. int    Del_wind()
  168. {
  169.     WINDFP  *p;
  170.     EDT_PTR *bfp;
  171.  
  172.     if ( topwfp == NULL )
  173.     return ERR;
  174.  
  175.     bfp = edt_top;
  176.  
  177.     top_ptr = topwfp->top_ptr_wfp;
  178.     lin_ptr = topwfp->lin_ptr_wfp;
  179.     ent_ptr = topwfp->ent_ptr_wfp;
  180.     btm_ptr = topwfp->btm_ptr_wfp;
  181.     Cur_X = topwfp->Cur_X_wfp;
  182.     Cur_Y = topwfp->Cur_Y_wfp;
  183.     Wrt_flg = topwfp->Wrt_flg_wfp;
  184.     Line_no = topwfp->Line_no_wfp;
  185.     Line_X = topwfp->Line_X_wfp; Line_Y = topwfp->Line_Y_wfp;
  186.     Woff_X = topwfp->Woff_X_wfp; Woff_Y = topwfp->Woff_Y_wfp;
  187.     Wscr_X = topwfp->Wscr_X_wfp; Wscr_Y = topwfp->Wscr_Y_wfp;
  188.     Wsiz_X = topwfp->Wsiz_X_wfp; Wsiz_Y = topwfp->Wsiz_Y_wfp;
  189.     Wind_flg = topwfp->Wind_flg_wfp; dlp_flg = topwfp->dlp_flg_wfp;
  190.     COLOR = topwfp->WCol_wfp;
  191.     Set_file_name(topwfp->name_wfp);
  192.     edt_top = topwfp->edt_top_wfp;
  193.     if ( Wind_flg == ERR )
  194.     Wind_flg = TRUE;
  195.  
  196.     p = topwfp->nxt_wfp;
  197.     free(topwfp);
  198.     topwfp = p;
  199.  
  200.     Kill_link(bfp);
  201.  
  202.     Set_vram();
  203.     Dsp_vram(vram);
  204.     Dsp_wrt_flg();
  205.     Dsp_free();
  206.  
  207.     return FALSE;
  208. }
  209. int    Wind_count()
  210. {
  211.     int     i;
  212.     WINDFP  *p;
  213.  
  214.     for ( p = topwfp,i = 0 ; p != NULL ; i++ )
  215.     p = p->nxt_wfp;
  216.     return i;
  217. }
  218. void    ReDsp_wind()
  219. {
  220.     int    i;
  221.  
  222.     memset(vram,0,MAX_X*2*MAX_Y);
  223.     ReSize_flg = TRUE;
  224.     for ( i = Wind_count(); i > 0 ; i-- ) {
  225.     Chng_wind();
  226.         Set_vram();
  227.     }
  228.     if ( topwfp != NULL )
  229.     Chng_wind();
  230.     ReSize_flg = FALSE;
  231.     if ( Wind_flg == ERR )
  232.     Wind_flg = TRUE;
  233.     Set_vram();
  234.     Dsp_vram(vram);
  235.     Dsp_wrt_flg();
  236.     Dsp_free();
  237. }
  238. void    ReSize_wind()
  239. {
  240.     int     ch,ec;
  241.  
  242.     wrtstr("ウインド・サイズの変更を行います",30,1,0x15);
  243.     for ( ; ; ) {
  244.     ch = Get_key(&ec);
  245.     if ( ec == 0x4D00 ) {
  246.         if ( --Woff_Y < 0 )
  247.         Woff_Y = 0;
  248.         else
  249.         Wsiz_Y++;
  250.     } else if ( ec == 0x5000 ) {
  251.         if ( Wsiz_Y > 5 ) {
  252.         Woff_Y++;
  253.         Wsiz_Y--;
  254.         }
  255.     } else if ( ec == 0x4F00 ) {
  256.         if ( (Woff_X-=4) < 0 )
  257.         Woff_X = 0;
  258.         else
  259.         Wsiz_X+=4;
  260.     } else if ( ec == 0x5100 ) {
  261.         if ( Wsiz_X > 20 ) {
  262.         Woff_X+=4;
  263.         Wsiz_X-=4;
  264.         }
  265.     } else if ( ec == 0x4D04 ) {
  266.         if ( --Wsiz_Y < 5 )
  267.         Wsiz_Y = 5;
  268.     } else if ( ec == 0x5004 ) {
  269.         Wsiz_Y++;
  270.         if ( (Woff_Y + Wsiz_Y) > MAX_Y )
  271.         Wsiz_Y = MAX_Y - Woff_Y;
  272.     } else if ( ec == 0x4F04 ) {
  273.         if ( (Wsiz_X-=4) < 20 )
  274.         Wsiz_X = 20;
  275.     } else if ( ec == 0x5104 ) {
  276.         Wsiz_X+=4;
  277.         if ( (Woff_X + Wsiz_X) >= MAX_X )
  278.         Wsiz_X = MAX_X - Woff_X;
  279.     } else if ( ec == 0x7300 || ec == 0x7200 ||
  280.             ec == 0x0100 || ec == 0x1D00 || ec == 0x4500 ) {
  281.         break;
  282.     }
  283.     if ( dlp_flg == FALSE &&
  284.          Woff_X == 0 && Woff_Y == 0 &&
  285.          Wsiz_X == MAX_X && Wsiz_Y == MAX_Y )
  286.         Wind_flg = FALSE;
  287.     else
  288.         Wind_flg = TRUE;
  289.     ReDsp_wind();
  290.     }
  291.     wrtstr(SPCSTR,30,1,0x1F);
  292. }
  293. void    ChgCol_wind()
  294. {
  295.     int    col;
  296.     static char  *menu[]={
  297.         "1   青   色  ",
  298.         "2   赤   色  ",
  299.         "3   紫   色  ",
  300.         "4   緑   色  ",
  301.         "5   水   色  ",
  302.         "6   黄   色  ",
  303.         "7   白   色  ",
  304.         NULL };
  305.  
  306.     col = COLOR-1;
  307.     if ( Sel_menu(menu,30,5,&col) != FALSE )
  308.         return;
  309.     COLOR = col+1;
  310.     if ( Wind_flg == ERR )
  311.     Wind_flg = TRUE;
  312. }
  313.